﻿<?=$this->load->view('include_header',null)?>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li class="current"><a href="<?=site_url('archive/idcard/'.$id)?>" class="report"><?=(empty($id))?"录入新":"编辑"?>客户基本信息</a></li>
				
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<div id="content">
			<div id="box">
			<form id="form" name="form" method="POST" action="<?=site_url('archive/employment_update/'.$cateid)?>">
			<fieldset>
			<legend>在职证明 Employer's Letter</legend>
			
			<label>姓名<br>Full Name:</label><input type="text" name="name" value="<?=@$info->name?>" /> <br /><br>
			<label>性别<br>Sex:</label><input type="radio" name="sex" value="1" <?= (@$info->sex==1)?'checked':''?> />男 / Male <input type="radio" name="sex" value="2" <?= (@$info->sex==2)?'checked':''?> />女 / Female 	<br /> <br>
			<label>出生日期<br>Date of Birth:</label><input type="text" name="birth" id="birth" value="<?=@$info->birth?>" /> <br /> <br>
			<label>护照编号<br>Passport No.:</label><input type="text" name="passport" value="<?= empty($info->passport) ? $_SESSION['passport_no'] : $info->passport?>" /> <br />	<br>
			<label>签证国家<br>Consular Of:</label><input type="text" name="dest_country" value="<?=@$info->dest_country?>" style="width: 400px;"/> <br />    <br>
            <label>月收入<br>Monthly Income:</label><input type="text" name="income" value="<?=@$info->income?>" /> <br /> <br>
			<label>担任职务<br>Position you hold:</label><input type="text" name="cap" value="<?=@$info->cap?>" /> <br /> <br>
			<span style='display:none'><label>组织 Name of Employer:</label><input type="text" name="organization" value="<?=@$info->organization?>" /> <br /> </span>
			<label>入职时间<br>Employment Date from:</label><input type="text" name="job_from" id="job_from" value="<?=@$info->job_from?>" onchange="check_date_rules()"/> <br /> <br>
			<span style='display:none'><label>工作时间至 Employment Date To:</label><input type="text" name="job_to" id="job_to" value="<?=@$info->job_to?>"  onchange="check_date_rules()"/> <br /></span>
			
			<label>签发时间<br>Date of Issued:</label><input type="text" name="sign_date" id="sign_date" value="<?=@$info->sign_date?>"  onchange="check_date_rules()"/> <br /> <br>
			<span style='display:none'><label>签发给 Issued to:</label><input type="text" name="sign_for" value="<?=@$info->sign_for?>" /> <br /></span>
			<label>签发单位<br>Issued by:</label><input type="text" name="sign_from" style="width:200px" value="<?=@$info->sign_from?>" /> <br /><br>
			<label>签发人职务<br>Position of Issuing Officer:</label><select type="text" name="sign_cap" value="<?=@$info->sign_cap?>" style="background: #FFFFC0;"><option>-</option></select> <br><br />
			<label>签发人<br>Issuing Officer:</label><input type="text" name="sign_man" value="<?=@$info->sign_man?>" /> <br /><br>
			<label>签发单位地址<br>Employer's Address:</label><input type="text" name="sign_address" size="50" value="<?=@$info->sign_address?>" /> <br />  <br>
			<label>签发单位电话<br>Employer's Telephone No.:</label><input type="text" name="sign_tel" value="<?=@$info->sign_tel?>" /> <br /><br>
						
			<input type="hidden" name="id" value="<?=$id?>" />
			<input id="button1" type="submit" value="提交信息 Continue" onclick="return check_date_rules()"/>
			<input id="button2" type="reset" value="重置 Cancel" />
			</fieldset>
			</form>
			</div>

		</div>
		
		<?=$this->load->view('include_sidebar',array('id'=>$id,'forms'=>$forms))?>
	</div>

	<script type="text/javascript">
    function check_date_rules() {
        if(convert_to_date($('#birth').val()).getTime() >  new Date().getTime()) {
            alert('[出生日期]不能大于[当前日期]！');
            return false;
        }         
        if(convert_to_date($('#job_from').val()).getTime() >  new Date().getTime()) {
            $('#job_from').focus();   
            alert('[入职时间]不能大于[当前日期]！');
            return false;
        }   
        if(convert_to_date($('#sign_date').val()).getTime() > new Date().getTime()) {
            $('#sign_date').focus();
            alert('[签发时间]不能大于[当前日期]！'); 
            return false;
        }                 
        return true; 
    }
      
	$().ready(function() {
	  $("#form").validate({
		rules: {
			name:{
			 required:true
			},
			sex:{
			 required:true
			},
			birth:{
			 required:true
			},
			passport:{
			 required:true
			},
			income:{
			 required:true
			},
			sign_date:{
			 required:true
			},
			/*sign_for:{
			 required:true
			},*/
			sign_from:{
			 required:true
			},
			sign_man:{
			 required:true
			}
		}
	  });
      
        $.datepicker.setDefaults(
            {
            dateFormat: 'dd/mm/yy',
            changeMonth: true,
            changeYear: true,
            showOn: "both",
            buttonImage: "images/calendar.gif",
            buttonImageOnly: true
            }
        );
        
		$( "#birth" ).datepicker();
		$( "#job_from" ).datepicker();
        $( "#sign_date" ).datepicker(); 
		/*$( "#job_to" ).datepicker({
			changeMonth: true,
			changeYear: true,
			showOn: "both",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true

		});*/
        
        get_select_options(f.sign_cap, sign_cap_arr, '<?=@$info->sign_cap?>'); 
	});

    var f = document.form;
    
    var sign_cap_arr = {
        'Director of HR' : '人事部主任',  
        'General Manager' : '总经理',  
        'Vice GeneralManager' : '副总经理',  
        'Director' : '主任',  
        'Manager' : '经理',  
        'Vice Manager' : '副经理'
    }
    
    function get_select_options(obj, kv, sv) {
        var arr = [];
        obj.options.length = 1;
        var i = 1;
        var selectedIndex = 0;
        for(var k in kv) {
            if(sv == k)  selectedIndex = i;
            obj.options[i++] = new Option(kv[k]+"-"+k, k);
        }
        obj.options.selectedIndex = selectedIndex;
    } 
	</script>
	
<?=$this->load->view('include_footer',null)?>
